package com.itheima.service.impl;

import com.itheima.mapper.UserMapper;
import com.itheima.pojo.User;
import com.itheima.service.UserService;
import org.apache.ibatis.io.Resources;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import org.apache.ibatis.session.SqlSessionFactoryBuilder;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.io.IOException;
import java.io.InputStream;
@Service
public class UserServiceImpl implements UserService {


    @Autowired
    private UserMapper mapper;

    @Override
    public boolean findByPhone(String phone) {
        //1.查询这个手机号的用户是否存在，
        User user = mapper.selectByPhone(phone);

        //2.如果不存在，创建一个用户存储到 mysql中
        if(user == null){
            User u = new User();
            u.setPhone(phone);
            u.setStatus(1);
            mapper.insert(u);
        }

        return true;
    }
}
